# coding=utf-8

from flask import render_template, g


def ops_render( template, context = {}) :
    """
    统一页面渲染
    :param template: 模板名称
    :param context:
    :return:
    """
    if  "current_user" in g :
        context["current_user"] = g.current_user
    return render_template( template,**context )


def get_values_by_request(request, name):
    return request[name] if name in request else ''


def gene_response_1(result):
    return gene_response_3(code=result["code"], msg=result["msg"], data=result["data"])


def gene_response_3(code=200, msg="", data={}):
    return {"code": code, "msg": msg, "data": data}

